/**++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++**
 *  @author     Andrew Wei
 *  @portfolio  http://andrewwei.mu
 *
 *  ©2012 Andrew Wei
 *
 *  This software is released under the MIT License:
 *  http://www.opensource.org/licenses/mit-license.php
 **++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++**/
package com.ghoztudios.events
{
    import flash.events.Event;
    import flash.events.ProgressEvent;

    /// @eventType  flash.events.DataLoadEvent.LOAD_COMPLETE
    [Event(name = "loadComplete", type = "flash.events.EnhancedProgressEvent")]

    /**
     * Custom progress event that allows custom data to be passed in.
     *
     * @langversion     3.0
     * @playerversion   Flash 10.3.183.20
     */
    public class EnhancedProgressEvent extends ProgressEvent
    {
        private static const ID:String = 'com.ghoztudios.events.EnhancedProgressEvent';


        // Events
        /**
         * Defines the value of the type property of a EnhancedProgressEvent object.
         * This event is dispatched whenever an object is loaded completely.
         *
         * @langversion     3.0
         * @playerversion   Flash 10.3.183.20
         */
        public static const LOAD_COMPLETE:String = "loadComplete";


        // Private Properties
        /**
         * Event type.
         *
         * @langversion     3.0
         * @playerversion   Flash 10.3.183.20
         */
        private var _type:String = null;

        /**
         * User data.
         *
         * @langversion     3.0
         * @playerversion   Flash 10.3.183.20
         */
        private var _data:Object = null;

        /**
         * Use bubbles.
         *
         * @langversion     3.0
         * @playerversion   Flash 10.3.183.20
         */
        private var _bubbles:Boolean = false;

        /**
         * Is cancelable.
         *
         * @langversion     3.0
         * @playerversion   Flash 10.3.183.20
         */
        private var _cancelable:Boolean = false;


        // Getter Methods
        /**
         * Gets the current event type.
         *
         * @langversion     3.0
         * @playerversion   Flash 10.3.183.20
         */
        override public function get type():String { return _type; }

        /**
         * Gets the user data.
         *
         * @langversion     3.0
         * @playerversion   Flash 10.3.183.20
         */
        public function get data():Object { return _data; }


        // Initialization
        /**
         * Creates a new EnhancedProgressEvent instance.
         *
         * @param   $type
         * @param   $data
         * @param   $bubbles
         * @param   $cancelable
         * @langversion     3.0
         * @playerversion   Flash 10.3.183.20
         */
        public function EnhancedProgressEvent($type:String, $data:Object = null, $bubbles:Boolean = false, $cancelable:Boolean = false):void
        {
            super($type, $bubbles, $cancelable);

            _type       = $type;
            _data       = $data;
            _bubbles    = $bubbles;
            _cancelable = $cancelable;
        }


        // Overridden Methods
        /**
         * @copy    flash.events.ProgressEvent#clone()
         * @langversion     3.0
         * @playerversion   Flash 10.3.183.20
         */
        public override function clone():Event
        {
            return new EnhancedProgressEvent(_type, _data, _bubbles, _cancelable);
        }
    }
}
